package com.zdy.pullrefresh;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.TextView;

import com.wang.avi.AVLoadingIndicatorView;

/**
 * Created by BBS-BBB on 2015/12/11.
 */
public class CustomProgressBarDialog extends Dialog {
    private LayoutInflater inflater;
    private Context mContext;
    private WindowManager.LayoutParams lp;
    View layout;

    /**
     * @param context
     */
    public CustomProgressBarDialog(Context context) {
        super(context, R.style.dialog);
        this.mContext = context;
        inflater = (LayoutInflater) mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        layout = inflater.inflate(R.layout.loading, null);
        setContentView(layout);
        // 设置window属性
        lp = getWindow().getAttributes();
        lp.gravity = Gravity.CENTER;
        lp.dimAmount = 0; // 去背景遮盖
        lp.alpha = 1.0f;
        getWindow().setAttributes(lp);

    }

    public void setText(String text) {
        TextView load = (TextView) layout.findViewById(R.id.load);
        load.setText(text);
    }

    public void show() {
        AVLoadingIndicatorView avloadingIndicatorView = (AVLoadingIndicatorView) layout.findViewById(R.id.avloadingIndicatorView);
        avloadingIndicatorView.postInvalidate();
        super.show();
    }

}
